<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <title>最常用出租屋管理系统</title>
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="stylesheet" href="__CDN__/layui/css/layui.css">
  <script src="__CDN__/layui/layui.js"></script>
  <script src="__CDN__/layui/js/jquery.min.js"></script>
  <link rel="stylesheet"
    href="__STATIC__/css/login.css?{if $Think.env.app_debug}_={:time()}{else /}v={$Think.config.tpadmin.version}{/if}">
</head>

<body>
  <style>
    html,
    body {
      width: 100%;
      height: 100%;
      background: url("__STATIC__/images/login-bg.jpg") no-repeat;
      background-size: 100% 100%;
    }

    .cavs {
      z-index: 1;
      position: fixed;
      width: 95%;
      margin-left: 20px;
      margin-right: 20px;
    }
  </style>
  <script src="__STATIC__/js/login.js"></script>
  <canvas class="cavs" width="1920" height="937"></canvas>

  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login">
    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>
          最常用出租屋管理系统
        </h2>
      </div>
      <form method="post">
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
          <div class="layui-form-item">
            <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username">
            </label>
            <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名"
              class="layui-input">
          </div>
          <div class="layui-form-item">
            <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password">
            </label>
            <input type="password" name="password" id="LAY-user-login-password" lay-verify="required|pass"
              placeholder="密码" class="layui-input">
          </div>
          <div class="layui-form-item" style="margin-top: 25px;">
            <input class="layui-btn layui-btn-lg layui-btn-fluid login" value="登录" lay-submit lay-filter="login"
              style="width:100%;" type="submit">
          </div>
      </form>
      <div class="layui-trans layadmin-user-login-footer">
        <p>
          ©2022 最常用
        </p>
      </div>
    </div>
  </div>

  <script>
    // main.init({ token: '{$token}' });
    $(function () {
      layui.use('form', function () {
        var form = layui.form;
        var that = this;
        //监听提交
        form.on('submit(login)', function (data) {
          layer.ready(function () {
            layer.load();
          });
          $.ajax({
            url: "{:url('Index/login')}",
            type: 'POST',
            // dataType: '',
            data: data.field,
            headers: {
              'X-CSRF-TOKEN': '{$token}'
            },
            success: function (data, status, xhr) {
              layer.close(layer.index);
              if (!data) {
                layer.msg('请求失败，请重试。');
              } else if (data.code === 0) {
                layer.msg(data.msg);
              } else {
                location.href = "{:url('Index/index')}";
              }
            },
            error: function (xhr, status, err) {
              layer.close(layer.index);
              layer.msg('请求失败，请重试。');
              opt.error && opt.error(xhr, status, err);
            }
          });
          return false;
        });
      });
    });   
  </script>
</body>

</html>